package com.wei.czz.framework.common.controller;

import com.wei.czz.common.annotation.Auth;
import com.wei.czz.common.dto.common.sms.SmsTemplateFlowDto;
import com.wei.czz.common.tool.Result;
import com.wei.czz.framework.common.manager.SmsTemplateManager;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2023-06-14 21:21:36
 * className: SmsTemplateFlowController
 * version: 1.0
 * description:
 */
@RestController
@RequestMapping("/sms-template-flow")
@AllArgsConstructor
public class SmsTemplateFlowController {

    private static final Logger log = LoggerFactory.getLogger(SmsTemplateFlowController.class);

    private final SmsTemplateManager smsTemplateManager;

    /**
     * 获取短信模板流水详情接口
     * <p>
     * 调用方：
     *  1、浏览器-后台-短信模板管理页面-短信模板流水查看抽屉中调用
     * @param masterId 主表主键
     * @param version  版本号
     * @return 结果
     */
    @GetMapping("/detail")
    @Auth(permit = "sms:template:get")
    public Result<SmsTemplateFlowDto> getSmsTemplateFlowDetail(@RequestParam("masterId") Long masterId,
                                                               @RequestParam("version") Integer version) {
        log.info("开始获取短信模板流水详情业务。masterId={} version={}", masterId, version);

        SmsTemplateFlowDto smsTemplateFlowDto = smsTemplateManager.getSmsTemplateFlowDetail(masterId, version);

        log.info("获取短信模板流水详情业务结束");
        return Result.success(smsTemplateFlowDto);
    }

}
